package com.safone.thirdattendanceservices.dormitory.controllers;


import com.safone.thirdattendanceservices.dormitory.services.DormitoryAttendanceDataService;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 第三方宿舍考勤数据接口
 * @author xy
 * @date 2020/12/4 20:16
 */
@RestController
@AllArgsConstructor
@RequestMapping(value = "/api/safe/external/open/dh")
public class DormitoryAttendanceDataController {

    private DormitoryAttendanceDataService dormitoryAttendanceDataService;

    /**
     * 查询所有宿舍楼某日考勤结果
     * @return
     */
    @GetMapping(value = "/dormitoryAttendance/find/All")
    public List<Map<String, Object>> findAllDormitoryAttendance(){
        return dormitoryAttendanceDataService.findAllDormitoryAttendance();
    }

    /**
     * 查询某栋宿舍楼某日考勤结果
     * @return
     */
    @GetMapping(value = "/dormitoryAttendance/find/one")
    public Map<String,Object> findOneDormitoryAttendance(@RequestParam("dormitoryId") Integer dormitoryId,@RequestParam("queryDate") String queryDate){
        return dormitoryAttendanceDataService.findOneDormitoryAttendance(dormitoryId.longValue(),queryDate);
    }

    /**
     * 根据条件查询宿舍节点
     * @return
     */
    @GetMapping(value = "/dormitory/find")
    public Object findDormitory(){
        return dormitoryAttendanceDataService.findDormitory();
    }

    /**
     * 根据名称模糊查询宿舍节点，返回信息包含上级节点
     * @return
     */
    @GetMapping(value = "/dormitory/search8name")
    public Object findDormitoryByName(){
        return dormitoryAttendanceDataService.findDormitoryByName();
    }

    /**
     * 查询所有宿舍楼
     * @return
     */
    @GetMapping(value = "/dormitory/get/all")
    public ResponseEntity<Map> getAllDormitory(){
        return dormitoryAttendanceDataService.getAllDormitory();
    }

    /**
     * 查询所有宿舍楼顶级节点学校
     * @return
     */
    @GetMapping(value = "/school/find/all")
    public List<Map<String, Object>> findSchool(){
        return dormitoryAttendanceDataService.findSchool();
    }

    /**
     * 查询学校和校区映射关系
     * @return
     */
    @GetMapping(value = "/map/find/all")
    List<Map<String, Object>> findCampus(){
        return dormitoryAttendanceDataService.findCampus();
    };
    /**
     * 通过学校id查询校区
     * @param pid 父级学校id
     * @return
     */
    @GetMapping(value = "/campus/find8pid")
    List<Map<String, Object>> findCampusByPid(@RequestParam("pid") String pid){
        return dormitoryAttendanceDataService.findCampusByPid(pid);
    };


}
